package com.zzhua.controller;

import com.zzhua.pojo.User;
import org.apache.shiro.SecurityUtils;
import org.springframework.web.bind.annotation.*;
import java.util.Map;

@RestController
public class Test2Controller {

    @RequestMapping("test")
    public Object test1(@RequestParam(value = "name",required = false) String name,
                        @RequestHeader(value = "token1",required = false) String token1,
                        @CookieValue(name = "ck",required = false) String ck,
                        @RequestBody(required = false) Map<String, Object> map) {
        System.out.println("请求参数: " + name);
        System.out.println("请求头: " + token1);
        System.out.println("请求体: " + map);
        System.out.println("cookie: " + ck);
        return "test2";
    }

    @RequestMapping("getCurrUser")
    public User getCurrUser() {
        Object principal = SecurityUtils.getSubject().getPrincipal();
        System.out.println(principal);
        return ((User) principal);
    }

}
